#!/bin/bash

echo "启动分布式缓存系统 - 3个节点"
echo "================================"

# 启动节点1
NODE_ID=1 PORT=3001 node server.js &
PID1=$!
echo "节点1启动完成 (PID: $PID1, 端口: 3001)"

# 启动节点2
NODE_ID=2 PORT=3002 node server.js &
PID2=$!
echo "节点2启动完成 (PID: $PID2, 端口: 3002)"

# 启动节点3
NODE_ID=3 PORT=3003 node server.js &
PID3=$!
echo "节点3启动完成 (PID: $PID3, 端口: 3003)"

echo ""
echo "所有节点已启动！"
echo "节点1: http://localhost:3001"
echo "节点2: http://localhost:3002"
echo "节点3: http://localhost:3003"
echo ""
echo "使用示例:"
echo "curl -XPOST -H \"Content-type: application/json\" http://localhost:3001/ -d '{\"myname\": \"电子科技大学@2023\"}'"
echo "curl http://localhost:3002/myname"
echo "curl -XDELETE http://localhost:3003/myname"
echo ""
echo "按 Ctrl+C 停止所有节点"

# 等待所有进程
wait
